﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using MySql.Data.MySqlClient;

namespace PTTPOS_Solution.DAL
{
    public static class Groupitems_DA
    {
        public static DataTable ListGroupitems=new DataTable();
        public static void GetListGroupitems()
        {
            MySqlCommand com = new MySqlCommand("select * from tblgroupitems", Connection_PTTPOS.GetConnection());
            com.Connection.Open();
            MySqlDataAdapter da = new MySqlDataAdapter(com);
            ListGroupitems.Clear();
            da.Fill(ListGroupitems);
            com.Connection.Close();
        }

        public static string findCategoryByGroupitem(string id_groupitem)
        {
            string str = "";
            MySqlCommand com = new MySqlCommand("select * from tblgroupitems where id=@id_groupitem", Connection_PTTPOS.GetConnection());
            com.Parameters.AddWithValue("@id_groupitem", id_groupitem);
            com.Connection.Open();
            MySqlDataReader reader = com.ExecuteReader(CommandBehavior.SingleRow);
            if (reader.Read())
            {
                str = reader["id_categories"].ToString();
            }
            com.Connection.Close();
            return str;
            
        }
    }
}
